﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.AUTH;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.Repository.Domain.AUTH;

namespace OpenAuth.Mvc.Controllers.AUTH
{
    public class Auth_Org_InfoController : BaseController
    {
        private Auth_Org_InfoApp _app;
        private Auth_UserApp _userapp;
        public Auth_Org_InfoController(IAuth auth, Auth_Org_InfoApp app, Auth_UserApp userapp) : base(auth)
        {
            _app = app;
            _userapp = userapp;
        }

        public string Load(Auth_Org_InfoListReq request) {
            var resp = new Response<List<Auth_Org_Info>> ();
            try
            {
                resp.Result = _app.load(request);
            }
            catch (Exception ex)
            {
                resp.Code = 500;
                    resp.Message = ex.Message;
            }
            return JsonHelper.Instance.Serialize(resp); 
        }
        public async Task<string> GetOrgUser(Auth_UserListReq request) 
        {
              var result = await _userapp.Load(request);

            return JsonHelper.Instance.Serialize(result);
        }

        public IActionResult Index()
        {
            return View();
        }
    }
}
